package com.example.search.model

import com.bawei.common.entity.SimpleVideoEntity
import com.example.common.model.BaseRepository
import com.example.search.api.SearchServerApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow

import javax.inject.Inject

class SearchRepository @Inject constructor(private val apiServer:SearchServerApi):BaseRepository<SearchServerApi>() {
    suspend fun getSimpleVideoByKeyword(keyword:String,page:Int,pagesize:Int): Flow<List<SimpleVideoEntity>> {
        return flow{
            val (code,data,msg)=apiServer.getSimpleVideoByKeyword(keyword,page,pagesize)
            if(code == 0){
                emit(data)
            }else{
                emit(listOf())
            }
        }
    }


}